import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { DataProvider } from "../../../../../fl/data/DataProvider";
import { ItemData } from "../../../resource/info/ItemData";
import { FlowerBg } from "../../common/FlowerBg";
import { ObjCreate } from "../../common/ObjCreate";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GBoxDirection } from "../../../../../com/mui/containers/globalVariable/GBoxDirection";
import { EatBeansItemCellRender } from "./EatBeansItemCellRender";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { GameProxy } from "../../../mvc/GameProxy";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
type int = number;
//class EatBeansEnterWin
    
    export  class EatBeansEnterWin extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(this.wWidth, this.wHeight);
            this.title = Language.getString(80373);
            this.titleHeight = 27;
            this._btn.addEventListener(flash.events.MouseEvent.CLICK, this.clickEnterCopyHandler);
            return;
        }

        public initBonuse(arg1: Array<any>): void
        {
            var loc3=0;
            var loc4=null;
            if (arg1 == null && arg1.length == 0) 
            {
                return;
            }
            var loc1=new DataProvider();
            var loc2=0;
            while (loc2 < arg1.length) 
            {
                loc3 = arg1[loc2];
                if ((loc4 = new ItemData(loc3)).itemInfo != null) 
                {
                    loc1.addItem(loc4);
                }
                ++loc2;
            }
            this._list.dataProvider = loc1;
            this._list.drawNow();
            return;
        }

        public updateTodayTimes(arg1: int, arg2: int): void
        {
            if (arg1 > arg2) 
            {
                arg1 = arg2;
            }
            this._txtTodayTimes.htmlText = Language.getStringByParam(80378, arg1, arg2);
            return;
        }

        public updateBonuse(arg1: Array<any>): void
        {
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            var loc1=new FlowerBg(437, 411);
            loc1.x = 16;
            loc1.y = 37;
            this.addChild(loc1);
            var loc2=ObjCreate.createGTextField("", 62, 278, 383, 50, this);
            var loc3=loc2.defaultTextFormat;
            loc3.size = 14;
            loc3.leading = 3;
            loc2.defaultTextFormat = loc3;
            loc2.htmlText = Language.getString(80374);
            this._ThiefView = new Object /* flash.display.Bitmap */();
            this._ThiefView.x = 70;
            this._ThiefView.y = 50;
            this.addChild(this._ThiefView);
            loc2 = ObjCreate.createGTextField("", this._ThiefView.x + 8, 240, 138, 100, this);
            loc3 = loc2.defaultTextFormat;
            loc3.leading = 3;
            loc2.defaultTextFormat = loc3;
            loc2.htmlText = Language.getString(80375);
            ObjCreate.createBg(this._ThiefView.x + 10, 92, 110, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(this._ThiefView.x + 10, 117, 110, 2, this, ImagesConst.SplitLine);
            this._defenderView = new Object /* flash.display.Bitmap */();
            this._defenderView.x = 258;
            this._defenderView.y = 50;
            this.addChild(this._defenderView);
            loc2 = ObjCreate.createGTextField("", this._defenderView.x + 8, 240, 138, 100, this);
            loc3 = loc2.defaultTextFormat;
            loc3.leading = 3;
            loc2.defaultTextFormat = loc3;
            loc2.htmlText = Language.getString(80393);
            ObjCreate.createBg(this._defenderView.x + 10, 92, 110, 2, this, ImagesConst.SplitLine);
            ObjCreate.createBg(this._defenderView.x + 10, 117, 110, 2, this, ImagesConst.SplitLine);
            loc2 = ObjCreate.createGTextField("", 131, 329, 200, 100, this);
            loc2.htmlText = Language.getString(80376);
            ObjCreate.createBg(32, 349, 405, 46, this, ImagesConst.RemainningTimeBg);
            this._list = ObjCreate.createTileList(66, 355, 340, 40, this);
            this._list.rowHeight = 40;
            this._list.columnWidth = 40;
            this._list.direction = GBoxDirection.HORIZONTAL;
            this._list.setStyle("cellRenderer", EatBeansItemCellRender);
            ObjCreate.createBg(40, 402, 405, 2, this, ImagesConst.SplitLine);
            this._btn = ObjCreate.createGButton(Language.getString(80377), 203, 415, 68, 25, this, "ButtonRed");
            this._btn.toolTipData = Language.getString(80371);
            this._txtTodayTimes = ObjCreate.createGTextField("", this._btn.x + 68, this._btn.y + 4, 170, 20, this);
            loc3 = this._txtTodayTimes.defaultTextFormat;
            loc3.align = flash.text.TextFormatAlign.CENTER;
            this._txtTodayTimes.defaultTextFormat = loc3;
            LoaderHelp.addResCallBack(ResFileConst.EatBeans, this.loadResComplete);
            return;
        }

        /* internal  */loadResComplete(): void
        {
            ObjCreate.createBitmap(ImagesConst.EatBeansThief, 63, 42, this);
            ObjCreate.createBitmap(ImagesConst.EatBeansBeansThief, 104, 55, this);
            ObjCreate.createBitmap(ImagesConst.EatBeansCanCollect, 111, 222, this);
            ObjCreate.createBitmap(ImagesConst.EatBeansKill, 251, 42, this);
            ObjCreate.createBitmap(ImagesConst.EatBeansDouJiangHun1, 292, 55, this);
            ObjCreate.createBitmap(ImagesConst.EatBeansCannotCollect, 287, 222, this);
            ObjCreate.createBitmap(ImagesConst.EatBeansBonus, 35, 323, this);
            this._ThiefView.bitmapData = GlobalClass.getBitmapData(ImagesConst.EatBeansThiefView);
            this._defenderView.bitmapData = GlobalClass.getBitmapData(ImagesConst.EatBeansDefenderView);
            return;
        }

        /* internal  */clickEnterCopyHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            GameProxy.copy.enterEatBeans();
            if (this._btn != null) 
            {
                this._btn.enabled = false;
                flash.utils.setTimeout(this.enabledOut, 3000);
            }
            return;
        }

        /* internal  */enabledOut(): void
        {
            if (this._btn == null) 
            {
                return;
            }
            this._btn.enabled = true;
            return;
        }

        /* internal */ /* const */wWidth: int=470;

        /* internal */ /* const */wHeight: int=456;

        /* internal */ /* var */_ThiefView: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_defenderView: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_btn: GButton;

        /* internal */ /* var */_txtTodayTimes: GTextFiled;
    }
